<script setup lang="ts">
import {
  downloadExcel,
  getOrderStatus,
  getOrderStatusList,
  setGoodsSupplier
} from "@/api/dashboard";
import { getBrandList } from "@/api/basic";
import { createDunningRecord } from "@/api/dunning";
import { createPaymentRecord } from "@/api/payment";
import { ref } from "vue";

const orderID = ref("DC202202161212901");

const getStatus = async () => {
  const res = await getOrderStatus(orderID.value);
  console.log(res);
};

const getStatusList = async () => {
  const res = await getOrderStatusList({
  });
  console.log(res);
};

const exportExcle = async () => {
  try {
    const blob = await downloadExcel({
      typeid: 1
    });
    const url = window.URL.createObjectURL(blob);
    const a = document.createElement("a");
    a.href = url;
    a.download = `订单导出_${new Date()
      .toLocaleDateString()
      .replace(/\//g, "-")}.xlsx`;
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    window.URL.revokeObjectURL(url);
  } catch (error) {
    console.error("导出失败", error);
  }
};

const getBrandListData = async () => {
  try {
    const res = await getBrandList();
    console.log("商品列表数据:", res);
  } catch (error) {
    console.error("获取商品列表失败", error);
  }
};
</script>

<template>
  <el-card>
    <template #header>
      <span>订单状态查询</span>
    </template>
    <div>
      <el-button type="primary" @click="getStatusList()"
        >查询订单状态</el-button
      >
    </div>
    <div>
      <el-button type="primary" @click="exportExcle()">导出订单</el-button>
    </div>
    <div>
      <el-button type="primary" @click="getBrandListData()"
        >获取商品列表</el-button
      >
    </div>
  </el-card>
</template>

<style scoped></style>
